// pages/login_test/login_test.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo:null,
  },


  wxlogin() {
    let that=this;
    wx.getUserProfile({
      desc: 'login&getinfo',
      success: (res) => {
        // console.log(res.userInfo);
        wx.login({
          success: (res1) => {
            // console.log(res1.code);
            wx.request({
              url: 'http://kr.aynakedu.com/api/wxlogin',
              data: {
                code: res1.code,
                UserInfo: res.userInfo,
              },
              method: "POST",
             success:(res2)=>{
               console.log(res2.data.userInfo);
               that.setData({
                userInfo:res2.data.userInfo,
               })
             }
            })

          }
        })
      },
      fail: (res) => {
        console.log("读取用户信息失败，请重试" + Error);
      },
    })
  }

})